package com.demo2do.fms.entity.data.cost;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.demo2do.core.utils.Alias;

/**
 * 
 * @author Ysy
 *
 */
@Alias("ton")
public enum Ton {
    
    Ton_0("0吨", new BigDecimal(0)),
    
    Ton_6("6吨", new BigDecimal(6)),
    
    Ton_7("7吨", new BigDecimal(7)),
    
    Ton_8("8吨", new BigDecimal(8)),
    
    Ton_9("9吨", new BigDecimal(9)),
    
    Ton_10("10吨", new BigDecimal(10));
	
	
    /** 描述 */
	private String description;
	
	/** 吨数 */
    private BigDecimal num;
    
    /**
     * 
     * @param description
     * @param ton
     */
    private Ton(String description, BigDecimal num) {
    	this.description = description;
        this.num = num;
    }
    
    /**
     * 
     * @return
     */
    public static int size() {
        return 6;
    }
    
    /**
     * select tons from original list
     * 
     * @param min
     * @param max
     * @return
     */
    public static List<Ton> filter(BigDecimal min, BigDecimal max) {
        
        List<Ton> tons = new ArrayList<Ton>();
        
        for(Ton ton : Ton.values()){

           //without filtering min OR the ton is greater than min
           if(min == null ? true : ton.num.compareTo(min) >= 0){
               
               //without filtering max OR the ton is less than min
               if(max == null ? true : ton.num .compareTo(max) <= 0){
                   
                   tons.add(ton);
                   
               }
           }
        }
        
        return tons;
    }
    
    /**
     * 
     * @return
     */
    public String getTonString(){
    	return this.num.toString();
    }
    
    /**
     * 
     * @return
     */
    public int getOrdinal(){
    	return this.ordinal();
    }

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @return the num
	 */
	public BigDecimal getNum() {
		return num;
	}

}
